<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>对象练习</title>
    <script>
        const stus = [{name:'小明',age:19}]

        function add(){
            const name = document.getElementById("name").value;
            const age = document.getElementById("age").value;
            const stu = {name:name,age:age};
            console.log(stu)
            stus.push(stu)
        }
        function show(){
            console.log(stus)
        }
    </script>
</head>
<body>
<div>
    <input id="name" placeholder="输入学生姓名"/>
    <input id="age" placeholder="请输入学生年龄"/>
    <button onclick="add()">添加学生</button>
    <button onclick="show()">打印全部学生</button>
</div>
</body>
</html>